package com.example.imageloader;

import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;

import com.example.imageloader.common.ImageOptions;
import com.example.imageloader.common.StrategyType;
import com.example.imageloader.impl.GlideImpl;
import com.example.imageloader.impl.PicassoImpl;

import java.io.File;

public class ImageLoaderManager implements IImageLoader{

    private IImageLoader iImageLoader;

    public ImageLoaderManager(StrategyType type){
        switch (type){
            case Glide:
                iImageLoader = new GlideImpl();
                break;
            case Picasso:
                iImageLoader = new PicassoImpl();
                break;
            case Fresco:
                break;
            default:
                iImageLoader = new GlideImpl();
                break;
        }
    }


    @Override
    public void loadFileIntoImageView(Context context, File file, ImageView target, ImageOptions options) {
        iImageLoader.loadFileIntoImageView(context,file,target,options);
    }

    @Override
    public void loadResourceIntoImageView(Context context, int source, ImageView target, ImageOptions options) {
        iImageLoader.loadResourceIntoImageView(context,source,target,options);
    }

    @Override
    public void loadByteArrayIntoImageView(Context context, byte[] bytes, ImageView target, ImageOptions options) {
        iImageLoader.loadByteArrayIntoImageView(context,bytes,target,options);
    }

    @Override
    public void loadUriIntoImageView(Context context, Uri uri, ImageView target, ImageOptions options) {
        iImageLoader.loadUriIntoImageView(context,uri,target,options);
    }

    @Override
    public void loadIntoImageView(Context context, String url, ImageView target, ImageOptions options) {
        iImageLoader.loadIntoImageView(context,url,target,options);
    }
}
